<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">

<link type="text/css" href="css/smoothness/jquery-ui-1.8.11.custom.css" rel="Stylesheet" />	
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.11.custom.min.js"></script>

<script type="text/javascript">
$(function() {
	$( "#startdate" ).datepicker({ altField: '#altstartdate', altFormat: 'yy-mm-dd' });
	$( "#startdate" ).datepicker( "option", "altField", '#altstartdate' );
	$( "#startdate" ).datepicker( "option", "altFormat", 'yy-mm-dd' );
	$( "#enddate" ).datepicker({ altField: '#altenddate', altFormat: 'yy-mm-dd' });
	$( "#enddate" ).datepicker( "option", "altField", '#altenddate' );
	$( "#startdate" ).datepicker( "option", "altFormat", 'yy-mm-dd' );
});

</script>
 
</head>
<body>
	<div class="main">
		<form action="FormGroups.php" method="post">
		<div id="groupdata">	
			<table>
				<thead><b>Group data</b></thead>
				<tr>
					<td>Group name: </td>
					<td><input type="text" name="groupname" size="10"></td>
				</tr>
				<tr>	
					<td>Duration: </td>
					<td><input type="text" name="startdate" id="startdate" /><input type="text" name="enddate" id="enddate" /></td>
				
				</tr>
				<tr>
					<td>Payment: </td>
					<td><input type="text" name="payment"></td>
				</tr>
				<tr>
					<td>Description: </td>
					<td><textarea name="description" rows="2" cols="50"></textarea> </td>
				</tr>
			</table>
			<input type="hidden" id="altstartdate" name="altstartdate">
			<input type="hidden" id="altenddate" name="altenddate">
		</div>	
		<input type="submit">
		</form>
		
		<div>
			<?php 
			    require 'dbconnect.php';
			    $groupname = &$_POST['groupname'];
			    $altstartdate = &$_POST['altstartdate'];
			    $altenddate = &$_POST['altenddate'];
			    $payment = &$_POST['payment'];
			    $description = &$_POST['description'];
		
			    if(isset($groupname)){
			        $query = sprintf("INSERT INTO groups(groupname, startdate, enddate, payment, description) 
			        VALUES('%s','%s','%s','%s','%s');",
			        mysql_real_escape_string($groupname), mysql_real_escape_string($altstartdate),
			        mysql_real_escape_string($altenddate), mysql_real_escape_string($payment),
			        mysql_real_escape_string($description));
		            mysql_query($query);
			    }
			?>
		</div>
	
	
		<div id="groupmembers">
		</div>
	
	
	
	</div>
</body>
</html>


<?php
